package main

import (
	"dh.com/store/common/wrapper"
	"dh.com/store/srv/goods/handler"
	"dh.com/store/srv/goods/proto/goods"
	"github.com/micro/go-micro"
	"github.com/micro/go-micro/registry/etcd"
	"github.com/micro/go-micro/util/log"
)

func main() {
	// New Service
	service := micro.NewService(
		micro.Name("com.dh.store.srv.goods"),
		micro.Version("2.0"),
		micro.Registry(etcd.NewRegistry()),
	)

	// Initialise service
	service.Init(
		micro.WrapHandler(wrapper.LogWrapper),
	)

	// Register Handler
	goods.RegisterGoodsHandler(service.Server(), handler.NewGoods(service.Client()))

	// Run service
	if err := service.Run(); err != nil {
		log.Fatal(err)
	}
}
